package com.example.note.dao;


import com.axdac.mixbind.sql.db.Entity;
import com.axdac.mixbind.sql.db.SQL;
import com.example.note.util.MyApplication;

import java.util.List;

public interface NoteDAO {
    @SQL("select * from T_NOTE;")
    @Entity(MyApplication.entityDir+".TNote")
    public List<Object> queryAll();

    @SQL("select * from T_NOTE order by ID desc;")
    @Entity(MyApplication.entityDir+".TNote")
    public List<Object> queryAllDesc();

    @SQL("select * from T_NOTE where title like @1 or content like @1 order by ID desc;")
    @Entity(MyApplication.entityDir+".TNote")
    public List<Object> queryQueryByKeyDesc(String searchKey);

    @SQL("select * from T_NOTE where ID=@1;")
    @Entity(MyApplication.entityDir+".TNote")
    public List<Object> queryByID(String ID);

    @SQL("select * from T_NOTE where noteTagID=@1;")
    @Entity(MyApplication.entityDir+".TNote")
    public List<Object> queryBynoteTagID(String noteTagID);

    @SQL("insert into T_NOTE (recordDate,title,noteTagID,content) values(@1,@2,@3,@4);")
    public boolean insert(String recordDate, String title, String noteTagID, String content);

    @SQL("update T_NOTE set title = @2 where ID = @1;")
    public boolean updateTitleByID(String ID, String title);

    @SQL("update T_NOTE set content = @2 where ID = @1;")
    public boolean updateContentByID(String ID, String content);

    @SQL("update T_NOTE set noteTagID = @2 where ID = @1;")
    public boolean updateNoteTagIDByID(String ID, String noteTagID);

    @SQL("update T_NOTE set noteTagID = '1'")
    public boolean refineNoteTagID();

    @SQL("SELECT * FROM T_NOTE LIMIT 1 offset (SELECT COUNT(*) - 1 FROM T_NOTE);")
    @Entity(MyApplication.entityDir+".TNote")
    public List<Object> queryLastInsert();



}
